//
//  AppDelegate+HuanXinSDK.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/9/5.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "AppDelegate+HuanXinSDK.h"

@implementation AppDelegate (HuanXinSDK)
+ (instancetype)shareAppDelegate{
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
- (void)initializeHuanXinSDKWithApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    //初始化
//    HOptions *option = [[HOptions alloc] init];
//    option.appkey = APPKEY_HuanXinSDK; // 必填项，appkey获取地址：kefu.easemob.com，“管理员模式 > 渠道管理 > 手机APP”页面的关联的“AppKey”
//    option.tenantId = TENANTID_HuanXinSDK;// 必填项，tenantId获取地址：kefu.easemob.com，“管理员模式 > 设置 > 企业信息”页面的“租户ID”
//    
//    //推送证书名字
//    //    option.apnsCertName = @"your apnsCerName";//(集成离线推送必填)
//    //Kefu SDK 初始化,初始化失败后将不能使用Kefu SDK
//    HError *initError = [[HChatClient sharedClient] initializeSDKWithOptions:option];
//    if (initError) { // 初始化错误
////        [CYAlert showInWindowWithTitle:NSLocalizedString(@"initialization_error", @"Initialization error!")  message:initError.errorDescription complete:nil];
//        return;
//    }
//    
//    //用户名和密码
//    NSString *username = [CYCache readDataWithKey:@"username"];
//    NSString *password = @"123456";
//    //注册
//    HError *registerError = [[HChatClient sharedClient] registerWithUsername:username password:password];
//    if (registerError) {//注册失败
////        [CYAlert showInWindowWithTitle:@"错误"  message:initError.errorDescription complete:nil];
//        //        return;
//    }
//    
//    //登录
//    HChatClient *client = [HChatClient sharedClient];
////    if (client.isLoggedInBefore != YES) {
//        HError *loginError = [client loginWithUsername:username password:password];
//        if (!loginError) { //登录成功
//             DeLog(@"登录成功");
//            
//        }
//        else{//登录失败
////            [CYAlert showInWindowWithTitle:@"错误" message:loginError.errorDescription complete:nil];
//            return;
//        
//        }
////    }
    
}

+ (void)initializeHuanXinSDKWithApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//    [self initializeHuanXinSDKWithApplication:application didFinishLaunchingWithOptions:launchOptions];
}
@end
